import React from 'react'
import { Button, Modal } from 'antd'
import { Checkbox, Form, Input, Select } from 'antd';
import { useState } from 'react';
import {useRef} from "react"
const { Option } = Select;

function Mymodel(props) {
    const myref = useRef(null)
    const [isModalOpen, setIsModalOpen] = useState(false);

    const showModal = () => {
        setIsModalOpen(true);
    };

    const handleOk = () => {
        setIsModalOpen(false);
    };

    const handleCancel = () => {
        props.ismodelshowfn(false)
    };
    const onFinish = (values) => {
        console.log('Success:', values);
        props.ismodelshowfn({
            values,
            data:false
        })
    };

    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    }
  const  onGenderChange = (value) => {
        switch (value) {
          case '正常':
            return;
    
          case '异常':
          
            return;
    
           default:
          
        }
    }
    return (
        <>
            <Modal title="Basic Modal" footer={null} onOk={handleOk} onCancel={handleCancel} visible={props.ismodelshow} forceRender >
                <Form
                    name="basic"
                    ref= {myref}
                    labelCol={{
                        span: 8,
                    }}
                    wrapperCol={{
                        span: 16,
                    }}
                    initialValues={{
                        remember: true,
                    }}
                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="菜单名称"
                        name="name"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your username!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="状态"
                        name="status"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your username!',
                            },
                        ]}
                    >
                        <Select
                            placeholder="请选择状态"
                            onChange={onGenderChange}
                            
                        >
                            <Option value="正常">正常</Option>
                            <Option value="异常">异常</Option>
                        </Select>
                    </Form.Item>
                    <Form.Item
                        label="日期"
                        name="date"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your username!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>


                    <Form.Item
                        wrapperCol={{
                            offset: 8,
                            span: 16,
                        }}
                    >
                        <Button type="primary" htmlType="submit">
                            确定
                        </Button>
                    </Form.Item>
                </Form>
            </Modal>
        </>
    );
}

export default Mymodel